home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-10 | 5.4 KB | 143 lines | [TEXT/PJMM] |
- unit vListDemo_Events;
-
- interface
- uses
- vListMngr, vListDemo_Globals, DemoList_Window, DemoList_Procs, InitTheMenus, HandleTheMenus;
-
- procedure HandleEvents (var doneFlag: BOOLEAN);
-
- implementation
- var {Main variables}
- myEvent: EventRecord; {Event record for all events}
- code: integer; {Determine event type}
- whichWindow: WindowPtr; {See which window for event}
- tempRect, OldRect: Rect; {Rect for dragging}
- mResult: longint; {Menu list and item selected values}
- theMenu, theItem: integer; {Menu list and item selected}
- chCode: integer; {Key code}
- ch: char; {Key pressed in Ascii}
- myPt: Point; {Temp Point, used in Zoom}
- dummy: BOOLEAN;
-
- procedure DoMouseDown;
- var
- dH, dV: INTEGER;
- begin
- if (code = inMenuBar) then{See if a menu selection}
- begin{Get the menu selection and handle it}
- mResult := MenuSelect(myEvent.Where);{Do menu selection}
- theMenu := HiWord(mResult);{Get the menu list number}
- theItem := LoWord(mResult);{Get the menu list item number}
- Handle_My_Menu(doneFlag, theMenu, theItem, activeTE);{Handle the menu}
- end;{End of inMenuBar}
-
- if (code = InDrag) then{See if in a window drag area}
- begin{Do dragging the window}
- tempRect := screenbits.bounds;{Get screen area, l,t,r,b, drag area}
- SetRect(tempRect, tempRect.Left + 10, tempRect.Top + 25, tempRect.Right - 10, tempRect.Bottom - 10);{}
- DragWindow(whichWindow, myEvent.where, tempRect);{Drag the window}
- end;{End of InDrag}
-
- if ((code = inGrow) and (whichWindow <> nil)) then
- begin{Handle the growing}
- SetPort(whichWindow);
- myPt := myEvent.where;
- GlobalToLocal(myPt);
- OldRect := WhichWindow^.portRect;
- with screenbits.bounds do{use the screens size}
- SetRect(tempRect, 15, 15, (right - left), (bottom - top) - 20);{l,t,r,b}
- mResult := GrowWindow(whichWindow, myEvent.where, tempRect); {Grow it}
- if mResult <> 0 then
- begin
- SetRect(tempRect, 0, 0, LoWord(mResult), HiWord(mResult)); {l,t,r,b}
- EraseRect(tempRect);
- SizeWindow(whichWindow, LoWord(mResult), HiWord(mResult), TRUE); {Resize to result}
- SetPt(myPt, whichWindow^.portRect.right, whichWindow^.portRect.bottom);
- SetRect(tempRect, 0, myPt.v - 15, myPt.h + 15, myPt.v + 15); {Position for horz scrollbar area}
- EraseRect(tempRect);
- InvalRect(tempRect); {Flag us to update it}
- SetRect(tempRect, myPt.h - 15, 0, myPt.h + 15, myPt.v + 15); {Position for vert scrollbar area}
- EraseRect(tempRect);
- InvalRect(tempRect); {Flag us to update it}
- {figure out how much window has changed}
- dH := (OldRect.right - OldRect.left) - LoWord(mResult);
- dV := (OldRect.bottom - OldRect.top) - HiWord(mResult);
- vLInsetList(dH, dV, DemoList); {}
- DrawGrowIcon(whichWindow);{Draw the grow Icon again}
- end; {if mResult <> 0}
- end; {End of growing}
-
- if (code = inContent) then
- begin {Handle the hit inside a window}
- if (whichWindow <> FrontWindow) then
- SelectWindow(whichWindow)
- else
- begin
- myPt := myEvent.where;
- GlobalToLocal(myPt);
- dummy := vLClick(myPt, myEvent.modifiers, DemoList);
- end;
- end; {inContent}
-
- if (code = inSysWindow) then{See if a DA selection}
- SystemClick(myEvent, whichWindow);{Let other programs in}
- end; {MouseDown}
-
- procedure HandleEvents (var doneFlag: BOOLEAN);
- begin
- if (activeTE <> nil) then{See if a TE is active}
- TEIdle(activeTE); {Blink the cursor if everything is ok}
- SystemTask; {For support of desk accessories}
-
- if GetNextEvent(everyEvent, myEvent) then{If event then...}
- begin {Start handling the event}
- code := FindWindow(myEvent.where, whichWindow);{Get which window the event happened in}
- case myEvent.what of{Decide type of event}
- MouseDown: {Mouse button pressed}
- DoMouseDown;
- KeyDown, AutoKey:
- {either a menu key or a TE entry}
- begin
- with myevent do
- begin
- chCode := BitAnd(message, CharCodeMask);
- ch := CHR(chCode);{Change to ASCII}
- theMenu := 0;
- if (Odd(modifiers div CmdKey)) then
- begin{}
- mResult := MenuKey(ch);
- theMenu := HiWord(mResult);
- theItem := LoWord(mResult);
- end; {CmdKey}
- if (theMenu <> 0) then
- Handle_My_Menu(doneFlag, theMenu, theItem, activeTE)
- else
- begin
- if (whichWindow = DemoListWindow) then
- vLKey(ch, modifiers, DemoList, TheListScrap);
- end; {theMenu = 0}
- end; {with MyEvent}
- end; {End for KeyDown,AutoKey}
-
- UpDateEvt: {Update event for a window}
- begin {Handle the update}
- whichWindow := WindowPtr(myEvent.message);
- BeginUpdate(whichWindow);
- Update_DemoList_Window(whichWindow);{Update this window}
- EndUpdate(whichWindow);{Return to normal clipping area}
- end; {End of UpDateEvt}
-
- ActivateEvt: {Window activated event}
- begin {Handle the activation}
- whichWindow := WindowPtr(myevent.message);
- if odd(myEvent.modifiers) then {Make sure it is Activate and not DeActivate}
- begin
- SelectWindow(whichWindow);
- if GetWRefCon(whichWindow) > 0 then
- DrawGrowIcon(whichWindow);
- end;
- end; {End of ActivateEvt}
- end; {End of case}
- end; {end of GetNextEvent}
- end; {procedure HandleEvents}
- end. {End of the unit}